package main

import (
	"fmt"
	"os"

	"github.com/goshark/gtimers/gtimers"
	"github.com/goshark/gziprsaes/gziprsaes"
)

func main() {

	//生成pem文件
	timer := gtimers.NewTimer()
	timer.SetInterval("1m")
	timer.SetRepeatcount(3)

	timer.SyncStart(func() {
		//读取公钥数据
		pubfile, err := os.Open("public.pem")
		defer pubfile.Close()
		if err != nil {
			fmt.Println(err)
		}
		pubfileinfo, err := pubfile.Stat()
		if err != nil {
			fmt.Println(err)
		}
		publickey := make([]byte, pubfileinfo.Size())

		_, err = pubfile.Read(publickey)
		if err != nil {
			fmt.Println(err)
		}
		aes_key := []byte("yanyuxuanyanyuxu")
		gziprsaes.CompresswithCipher("data.file", publickey, aes_key)

	})
}
